import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenExcelButton } from '../Common/options'

export const SafetyHazards = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <OpenExcelButton
                key="open"
                title="批量导入"
                OptionsEvent={OptionsEvent}
                data={{
                    submit: true,
                    save: true,
                    url: 'getYangPuGetExcelTemp',
                    pos: 'posYangPuUploadExcelInfo',
                    ExcelTempType: 'SC_SafetyHazards',
                }}
            />,
            <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'SafetyHazards' },
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },

            {
                dataIndex: 'hazardLocation',
                title: '隐患部位',
                valueType: 'input',
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'hazardDescription',
                title: '隐患简述',
                valueType: 'input',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'problemCount',
                title: '存在问题数量',
                valueType: 'input',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'inspectionDate',
                title: '检查日期',
                valueType: 'Date',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'rectificationNoticeNo',
                title: '整改通知书编号',
                valueType: 'input',
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'rectificationDeadline',
                title: '整改期限',
                valueType: 'input',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'implementationStatus',
                title: '落实情况',
                valueType: 'select',
                valueEnum: { 已整改: '已整改', 未整改: '未整改' },
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'reinspectionDate',
                title: '复查日期',
                valueType: 'Date',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'acceptancePerson',
                title: '验收人',
                valueType: 'input',
                rules: true,
                width: 200,
            },
            commonTableList.updateUserName,
            commonTableList.updateTime,
            commonTableList.BeginSecurityDate,
            commonTableList.EndSecurityDate,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 400,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
